# -*- coding: utf-8 -*-



from django.shortcuts import render,HttpResponse
from .models import New
import json
# Create your views here.
def home(request):
    content = {
        'name':'gay',
        'sex':'1'

    }
    return render(request,"home.html",content)
def new(request):
    news = New.objects.all()
    return render(request,'new.html',context={'n':news})


def ajax(request):
    news = New.objects.all()
    content = []
    for item in news:
        content.append(item.getattrs())
    content = json.dumps(content)
    if request.is_ajax():
        return HttpResponse(content,content_type='application/json')
    else:
        return render(request,template_name='new.html')